/**
 * 
 */
package com.scaffold.commons.config;

/**
 * @author wangjg
 *
 */
public abstract class AbstractConfig {

	public abstract String getString(String key);

	public Boolean getBoolean(String key) {
		String value = this.getString(key);
		if(value==null)return null;
		return Boolean.valueOf(value);
	}

	public Boolean getBoolean(String key, boolean defaultValue) {
		String value = this.getString(key);
		if(value==null)return defaultValue;
		return Boolean.valueOf(value);
	}

	public Short getShort(String key, short defaultValue) {
		Short v = this.getShort(key);
		return v!=null ? v : defaultValue;
	}

	public Short getShort(String key) {
		String value = this.getString(key);
		if(value==null)return null;
		return Short.valueOf(value);
	}

	public Integer getInteger(String key, int defaultValue) {
		Integer v = this.getInteger(key);
		return v!=null ? v : defaultValue;
	}

	public Integer getInteger(String key) {
		String value = this.getString(key);
		if(value==null)return null;
		return Integer.valueOf(value);
	}

	public Long getLong(String key, long defaultValue) {
		Long v = this.getLong(key);
		return v!=null ? v : defaultValue;
	}

	public Long getLong(String key) {
		String value = this.getString(key);
		if(value==null)return null;
		return Long.valueOf(value);
	}

}